package com.gyf.base.rx

import com.gyf.base.common.BaseConstant
import com.gyf.base.data.protocol.BaseResp
import rx.Observable
import rx.functions.Func1

class BaseFunc<T> : Func1<BaseResp<T>, Observable<T>> {
    override fun call(t: BaseResp<T>): Observable<T> {
        if (t.status != BaseConstant.RESUlT_CODE) {
            return Observable.error(BaseException(t.status, t.message));
        }
        return Observable.just(t.data);
    }
}